/* 
 * This program is free software; you can redistribute it and/or modify 
 * it under the terms of the GNU General Public License as published by 
 * the Free Software Foundation; either version 3 of the License, or 
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but 
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
 * for more details.
 * 
 * You should have received a copy of the GNU General Public License along 
 * with this program; if not, write to the Free Software Foundation, Inc., 
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */

#ifndef IMAGEVIEW_H
#define IMAGEVIEW_H

#include <QBuffer>
#include <QByteArray>
#include <QMovie>
#include <QWidget>
#include <QLabel>
#include <QGraphicsItem>
#include <QListWidgetItem>
#include "extracontainer.h"
#include "imagewidget.h"

class MainWindow;
class ImageWidget;
namespace Ui
{
	struct ImageViewForm;
}

class ImageViewForm : public QWidget
{
	Q_OBJECT
public:
	ImageViewForm(MainWindow* mainform, QWidget* widget = 0);
	virtual ~ImageViewForm();
	void setExtraContainer(const Wishmaster::ExtraContainer& cont, const QByteArray& postHid);
	Ui::ImageViewForm* getUI();
	void viewByID(int id);
	void viewByPath(const QString& path);
	void update();

	bool hidExists(const QByteArray& postHid); // Hack
	ImageWidget* showStaticImage(const QImage& image, const QByteArray& postHid);
	ImageWidget* showAnimatedImage(const QByteArray& image, const QByteArray& postHid);
protected:
	virtual void closeEvent(QCloseEvent* event);
	virtual void showEvent(QShowEvent* event);
	virtual bool event(QEvent* event);

public slots:
	void deleteTag();

protected slots:
	void zoom_click();
	void unzoom_click();
	void save_click();
	void saveAsFile();
	void addTag();
	void close_click();
	void saveandclose_click();
	void fut_click(QListWidgetItem* item);
	void tagContextMenu(const QPoint& p);
	void extraSave(QModelIndex index);
	void hideExtraBox();
	void showExtraBox();
	void tabChanged(int i);
	void tabClose(int i);
	void tagChanged(const QString& tag);

	void emptyTagLine();

protected:
	ImageWidget* getImageWidget(const QByteArray& postHid);
	void fillExtra(const Wishmaster::ExtraContainer& cont);

private:
	Ui::ImageViewForm* m_ui;
	MainWindow* m_mainform;
	QString m_imagedir;
	bool m_animated;
	QIcon m_savedIcon;

	QStringList m_tags;
	int m_prevtab;
};

#endif

